package com.example.utils.cos;

import javax.activation.MimetypesFileTypeMap;
import java.io.File;

public class ContentTypeUtils {

    public static String getContentType(String fileUrl) {
        String contentType = null;
        try {
            contentType = new MimetypesFileTypeMap().getContentType(new File(fileUrl));
        } catch (Exception e) {
            e.printStackTrace();
        }
        System.out.println("getContentType, File ContentType is : " + contentType);
        return contentType;
    }

    public static void main(String[] args) {
        String fileUrl = "D:/1.png";
        String contentType = getContentType(fileUrl);
        System.out.println(contentType);
    }

}